import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/components/layout/layout.vue'
import Login from '@/components/login/index.vue'
import Dashboard from "@/components/dashboard/index.vue";
import changePwd from "@/components/layout/changePwd.vue";
import detection from "./detection.js";
import infomation from "./infomation.js";
import urgent from "./urgent.js";


// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)

}
Vue.use(Router)

let stateSource = [{
  path: '/dashboard',
  component: Layout,
  name: 'Dashboard',
  hidden: true,
  redirect: '/dashboard/',
  children: [{
    path: '/',
    name: 'dashboard',
    component: Dashboard,
    meta: {
      title: '工作台'
    },
  },{
    path: '/changePwd',
    name: 'changePwd',
    component: changePwd,
    meta: {
      title: '修改密码'
    },
  }]
}, {
  path: "*",
  redirect: "/dashboard",
  hidden: true
}, {
  path: '/login',
  component: Login,
  name: 'login',
  hidden: true
},]
let constantRouterMap = [...detection, ...infomation,...urgent]
const routes = [...stateSource, ...constantRouterMap];
export default new Router({
  routes: routes,
  base: '/framework/',
  mode: "hash"
})

//3.导出router
export {constantRouterMap}

